package com.lobobrowser.encoder;

import sun.misc.BASE64Encoder;

public class Key {

	public static String KEY_TAG = "KEY";
	private String key;
	private int size;
	
	
	
	public Key(int size){
		this.size = size;
		init();
	}
	
	private void init(){
		this.key = "";
		for (int i= 0; i< this.size; i++){
			this.key = this.key + (char)(33 + Math.round((Math.random() *90)));
		}
		
		BASE64Encoder b64str = new BASE64Encoder();
		
		byte [] bArray = this.key.getBytes(); 
		this.key = b64str.encode(bArray);
		
	}
	
	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}
	
	public static void main(String [] args){
		Key n = new Key(2);
		System.out.println(n.getKey());
	}
	
	public String toString(){
		return this.key;
	}
	
}
